﻿namespace WebinatorTest.IntegrationTests
{
    using System.Collections.Generic;
    using System.Threading;
    using NUnit.Framework;
    using Webinator;

    [TestFixture]
    public class ConcurrencyTests
    {
        [Test]
        public void SpinUpTenInstances()
        {
            var threads = new List<Thread>();

            for (var i = 0; i < 10; i++)
            {
                threads.Add(new Thread(() => WebManagerFactory.CreateInstance(new Config { BaseUrl = "google.com" }).SendKeys(LocateBy.Name("q"), "cheese")));
            }

            foreach (var thread in threads)
            {
                thread.Start();
            }

            foreach (var thread in threads)
            {
                thread.Join();
            }
        }

        [TestFixtureTearDown]
        public void FixtureTearDown()
        {
            WebManagerFactory.CloseInstances();
        }
    }
}